﻿using IDAL;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAL
{
    public class D_Taste : ITaste
    {
        public void Add(Taste item)
        {
            CakeEntities db = new CakeEntities();
            db.Taste.Add(item);
            db.SaveChanges();
        }

        public void Delete(int id)
        {
            CakeEntities db = new CakeEntities();
            db.Taste.Remove(db.Taste.Find(id));
            db.SaveChanges();
        }

        public Taste FindById(int id)
        {
            CakeEntities db = new CakeEntities();
            return db.Taste.Find(id);
        }

        public List<Taste> GetAll()
        {
            CakeEntities db = new CakeEntities();
            return db.Taste.ToList();
        }

        public void Updata(int id, Taste item)
        {
            CakeEntities db = new CakeEntities();
            var data= db.Taste.Find(id);
            if (data!=null)
            {
                data.TasteName = item.TasteName;
                db.SaveChanges();
            }
        }
    }
}
